<template>
  <el-container class="home-container">
    <el-header>
      <router-link style="text-decoration: none;" to="/home">
        <div class="logo_tile">
          <h2>报价管理系统-客户</h2>
        </div>
      </router-link>
      <div class="logo_tile">
        <span> 欢迎：<i class="el-icon-arrow-left"></i>{{nowCustomer.name}}<i class="el-icon-arrow-right"></i> </span>
        <el-button @click="logout" type="info">退出</el-button>
      </div>
    </el-header>
    <el-card>
      <el-menu
        class="el-menu-vertical-demo"
        router
        unique-opened
        active-text-color="#409EFF"
        mode="horizontal">
        <el-submenu index="index1" style="margin-top: -20px">
          <template slot="title">我的订单</template>
          <el-menu-item @click="ddchoose(3)">待支付订单</el-menu-item>
          <el-menu-item @click="ddchoose(4)">已支付订单</el-menu-item>
          <el-menu-item @click="ddchoose(5)">已转合同订单</el-menu-item>
        </el-submenu>
        <el-submenu index="index" style="margin-top: -20px">
          <template slot="title">发票管理</template>
          <el-menu-item index="/addpay">申请发票</el-menu-item>
          <el-menu-item index="/paylist">发票列表</el-menu-item>
        </el-submenu>
      </el-menu>
    </el-card>
    <!-- 右侧的 主体区域 -->
    <el-main>
      <router-view></router-view>
    </el-main>
    <span style="color: gray; position: fixed; bottom: 0; right: 0;">报价管理系统</span>
  </el-container>
</template>

<script>
  export default {
    name: "client",
    data() {
      return {
        nowCustomer: {}
      }
    },
    methods: {
      logout: function () {
        sessionStorage.removeItem("customer");//退出之前先清除sessionStorage中user信息
        this.$router.push('/customerLogin') //退出到登录页
      },
      ddchoose(state) {
        this.$router.push(
          {
            path: '/orderCus',
            query: {state}
          }
        )
        this.$router.go(0)
      }
    },
    mounted() {
      this.nowCustomer = JSON.parse(sessionStorage.getItem("customer"))
      let userId = this.nowCustomer.id;
    }
  }
</script>

<style lang="less" scoped>
  .home-container {
    height: 100%;
  }

  .el-header {
    background-color: #373d41;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0;
    user-select: none;

    .logo_tile {
      display: flex;
      align-items: center;
      color: white;

      h2 {
        font-weight: 200;
        margin-left: 15px;
      }
    }

    .el-button {
      margin-right: 10px;
    }
  }

  .el-aside {
    background-color: #333744;
    user-select: none;
  }

  .el-main {
    background-color: #eaedf1;
  }

  .iconfont {
    margin-right: 8px;
  }

  .toggleBar {
    color: #fff;
    font-size: 12px;
    line-height: 24px;
    background-color: #4a5064;
    text-align: center;
    letter-spacing: 0.2em;
    cursor: pointer;
    user-select: none;
  }

  .el_submenu_large {
    width: 200px;
  }

  .el_submenu_small {
    width: 65px;
  }
</style>
